<?php
/*
	La classe modèle pour les Catégories.
*/
class Model_Recherche extends Model_Template{
	
	public function __construct(){
		parent::__construct();
		
		$sql = 'SELECT idInscrit, age, sexe, situationAmour, typeRencontre FROM Recherche';
		$this->selectAll = Controller_Template::$db->prepare($sql);
		
		$sql = 'INSERT INTO Recherche (idInscrit, age, sexe, situationAmour, typeRencontre) VALUES (:idInscrit, :age, :sex, :situationA, :typeR)';
		$this->insert = Controller_Template::$db->prepare($sql);
		
		$sql = 'UPDATE Recherche SET age = :age, sexe = :sex, situationAmour = :situationA, typeRencontre = :typeR WHERE idInscrit = :id';
		$this->update = Controller_Template::$db->prepare($sql);
		
		$sql = 'DELETE FROM Recherche WHERE idInscrit = ?';
		$this->delete = Controller_Template::$db->prepare($sql);
		
		$sql = 'SELECT idInscrit, age, sexe, situationAmour, typeRencontre FROM Recherche WHERE id = ?';
		$this->selectById = Controller_Template::$db->prepare($sql);
		
	}
	
	public function addRech($idIn, $age, $sex, $situationA, $typeR) {
		$this->insert->execute(
		array(':nom' => $idin, ':prenom' => $age, ':pseudo' => $sex, ':mdp' => $situationA, ':dateNaiss' => $typeR));
		return $this->insert->rowCount();
	}
	
	public function modifRech($age, $sex, $situationA, $typeR) {
		$this->update->execute(
		array(':age' => $age, ':sex' => $sex, ':pseudo' => $pseudo, ':situationA' => $situationA, ':typeR' => $typeR));
		return $this->update->rowCount();
	}
}

